package org.meichao.demo.service.sequence;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class SequenceThread {

    /**
     * 多个线程顺序执行
     */
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(3);

        Thread a = new java.lang.Thread(() -> System.out.println("a"));
        Thread b = new java.lang.Thread(() -> System.out.println("b"));
        Thread c = new java.lang.Thread(() -> System.out.println("c"));

        CompletableFuture.runAsync(a, executorService).thenRun(b).thenRun(c);
        executorService.shutdown();
    }
}
